package luogu;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;
import java.io.PrintWriter;

public class P3156 {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        StreamTokenizer st = new StreamTokenizer(br);

        // 读取学生个数 n 和询问次数 m
        st.nextToken();
        int n = (int) st.nval;  // 学生个数
        st.nextToken();
        int m = (int) st.nval;  // 询问次数

        // 存储学号的数组
        int[] id = new int[n];

        // 读取学号
        for (int i = 0; i < n; i++) {
            st.nextToken();
            id[i] = (int) st.nval;
        }

        // 处理查询并输出结果
        for (int j = 0; j < m; j++) {
            st.nextToken();
            int index = (int) st.nval;
            // 因为输入的查询索引是从 1 开始的，所以我们需要减去 1
            pw.println(id[index - 1]);
        }

        // 关闭 PrintWriter
        pw.flush();
        pw.close();
        br.close();
    }
}